package net.fkzg.framework;

import lombok.extern.slf4j.Slf4j;
import net.fkzg.framework.application.DistStaticResourceHandler;
import net.fkzg.framework.util.EnvUtil;
import org.smartboot.http.restful.RestfulBootstrap;
import org.smartboot.http.server.HttpBootstrap;
import uk.org.lidalia.sysoutslf4j.context.SysOutOverSLF4J;

import java.net.InetAddress;

@Slf4j
public class TerminalApplication {

    public static void main(String[] args) throws Exception {
        SysOutOverSLF4J.sendSystemOutAndErrToSLF4J();
        RestfulBootstrap bootstrap = RestfulBootstrap.getInstance(new DistStaticResourceHandler())
                .scan("net.fkzg.framework");
        int port = Integer.parseInt(EnvUtil.getPropValue("http.port", "8080"));
        HttpBootstrap httpBootstrap = bootstrap.bootstrap();
        httpBootstrap.configuration().bannerEnabled(false);
        httpBootstrap.setPort(port).start();
        log.info("点击打开地址：http://{}:{}", InetAddress.getLocalHost().getHostName(), port);
        log.info("########################{}服务启动成功！########################", TerminalApplication.class.getSimpleName());
    }

}
